/**
 * 
 */
package com.hfjyz.registration.service;

import java.util.Calendar;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.transaction.annotation.Transactional;

import com.hfjyz.registration.contants.ExamContants;
import com.hfjyz.registration.dao.LoggingDao;
import com.hfjyz.registration.model.Exam;
import com.hfjyz.registration.model.Logging;

/**
 *
 */
public class AbstractServiceImpl implements BaseService {
	private LoggingDao loggingDao;

	@Transactional
	@Override
	public void loggin(HttpServletRequest request, String logtype, Integer uid,
			String usertype, String username, String operator, String remark) {

		Date logtime = Calendar.getInstance().getTime();
		String ip = request.getRemoteAddr();
		Exam exam = (Exam) request.getSession().getAttribute(
				ExamContants.SESSION_KEY_EXAM_INFO);
		String examName = "";
		if (exam != null) {
			examName = exam.getName();
		}
		Logging l = new Logging(logtype, usertype, username, uid, logtime, ip,
				remark, examName);
		try {
			loggingDao.add(l);
		} catch (Exception e) {
		}
	}

	/**
	 * @return the loggingDao
	 */
	public LoggingDao getLoggingDao() {
		return loggingDao;
	}

	/**
	 * @param loggingDao
	 *            the loggingDao to set
	 */
	public void setLoggingDao(LoggingDao loggingDao) {
		this.loggingDao = loggingDao;
	}
}
